<!DOCTYPE html >
<html response.AddHeader( "Access-Control-Allow-Origin", "*"); response.AddHeader( "Access-Control-Allow-Methods", "PUT,GET,POST,OPTIONS"); response.AddHeader( "Access-Control-Allow-Headers", "X-Requested-With, Content-Type, X-File-Name");>

	<head>
		<meta charset="UTF-8">
		<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
		<link rel="stylesheet" href="css/home.css">
		<link rel="stylesheet" href="css/base.css">
		<!--<link href="css/index.css" type="text/css" rel="stylesheet" />-->
		<script type="text/javascript" src="http://api.map.baidu.com/api?key=&v=1.1&services=true"></script>
		<script type="text/javascript" src="js/jquery-3.2.1.js"></script>
		<script type="text/javascript" src="js/index.js"></script>
		<script type="text/javascript" src="js/setting.js"></script>
		<!--<script type="text/javascript" src="js/compangImg.js"></script>-->
		<script type="text/javascript" src="js/personInfro.js"></script>
		<title>舆情定制</title>
	</head>

	<body>
		<div class="wholePublic-box">
			<div class="wholePublic-header clearfix">
				<div class="wholePublic-logo fl ">
					<a href="index-logged.html"><img src="images/logo-2.png" /></a>
				</div>
				<div class="wholePublic-header-list fl">
					<ul class="clearfix">
						<li onclick="javascript:window.location='wholePublic-company.html'">全部舆情</li>
						<li onclick="javascript:window.location='my-custom.html'">舆情定制</li>
						<li onclick="javascript:window.location='analysis.html'">分析报告</li>
						<li onclick="javascript:window.location='thinkTank.html'">智库</li>
						<li onclick="javascript:window.location='contactUs.html'">联系我们</li>
					</ul>
				</div>
				<div class="wholePublic-header-right fr">
					<ul class="clearfix">
						<li id='line'><img src="images/line-2.png" /></li>
						<li onclick="javascript:window.location='my-custom.html'">我的定制</li>
						<li id="exit"><img src="images/exit-2.png" /></li>
						<li class="setting-icon">
							<div id="setting-icon"><img src="images/setting-icon.png" /></div>
							<div class="setting-list">
								<span class="setting-arrow"></span>
								<ul>
									<li onclick="javascript:window.location='company-setting.html'">企业认证</li>
									<li onclick="javascript:window.location='financial-setting.html'">财务中心</li>
								</ul>
							</div>
						</li>
					</ul>

				</div>

			</div>
			<div class="grcolor-box"></div>

			<div class="container">
				<div class="setting-line">
					<ul class="clearfix">
						<li>企业认证</li>
						<li class="setting-line-selected">申请管理员认证</li>
					</ul>
				</div>
				<!--企业管理认证-->
				<div class="setting-item" id="manage">
					<div class="up-infro">
						<div class="company-setting-title">管理员信息</div>
						<div><span>管理员姓名</span><input placeholder="输入管理员姓名" class="input-1" id="ma_name" /></div>
						<div><span>所属企业部门与职位</span><input placeholder="输入所属企业部门+职位" class="input-4" id="ma_position" /></div>
						<div><span>管理员手机号码 </span><input type="tel" placeholder="输入管理员手机号码 " class="input-1" id="ma_phone" /></div>
						<div><span>管理员邮箱 </span><input type="email" placeholder="输入管理员邮箱" class="input-1" id="ma_email" /></div>
						<div><span>管理员身份证号码</span><input placeholder="输入管理员身份证号码" class="input-1" id="ma_idcard" /></div>
						<div id="ma_icimg"><span>身份证上传</span><button class="btn-add-pic">点击上传</button></div>
						<div class="ID_card_box">
							<div class="clearfix">
								<div class="fl ident-img">
									<div class="clearfix">
										<div class="imgBox2">
											<div class="addIcon">+</div>
											<div>正面</div>
										</div>
									</div>
									<img src="" alt="未显示" id="img2" width="300px" height="200px" />
									<div id="container2">
										<input type="file" id="pickfile2" value="">
									</div>
								</div>
								<div class="fl ident-img">
									<div class="clearfix">
										<div class="imgBox2">
											<div class="addIcon">+</div>
											<div>反面</div>
										</div>
									</div>
									<img src="" alt="未显示" id="img3" width="300px" height="200px" />
									<div id="container3">
										<input type="file" id="pickfile3" value="">
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="whole-btn company-btn" onclick="addManager()"><button>申请</button></div>

				</div>

			</div>

		</div>
	</body>

</html>
<script src="js/imgUp/jquery.min.js"></script>
<script src="js/imgUp/plupload.full.min.js"></script>
<script src="js/imgUp/qiniu.js"></script>
<script src="js/imgUp/myUploader1.js"></script>
<script>
	//截公司id
	var companyUrl = window.location.href;
	var companyId;
	if(companyUrl.lastIndexOf("=") != -1) {
		var companyData = companyUrl.split("=");
		companyId = decodeURI(companyData[1]);
	};

	IdImg('pickfile2', 'container2', 'img2');
	IdImg('pickfile3', 'container3', 'img3')
	
	//页面跳转
	$(".setting-line ul li").eq(0).click(function(){
		window.location.href="company-setting.html";
	})
	
	//上传身份证
	$(".btn-add-pic").click(function() {
		$(".ID_card_box").show();
	});

	//企业管理认证
	$("#manage input").focus(function() {
		$(this).css("border", "1px solid white");
	});
	
	function addManager() {
		var ma_phone = /^[1][3,4,5,7,8][0-9]{9}$/;
		var ma_email = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/;
		var ID_card = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
		if($("#ma_name").val() == "") {
			$("#ma_name").css("border", "1px solid #d63d3f");
			return false;
		} else if($("#ma_position").val() == "") {
			$("#ma_position").css("border", "1px solid #d63d3f");
			return false;
		} else if($("#ma_phone").val() == "") {
			$("#ma_phone").css("border", "1px solid #d63d3f");
			return false;
		} else if(!ma_phone.test($("#ma_phone").val())) {
			$("#ma_phone").css("border", "1px solid #d63d3f");
			alert("请输入正确格式的手机号");
			return false;
		} else if($("#ma_email").val() == "") {
			$("#ma_email").css("border", "1px solid #d63d3f");
			return false;
		} else if(!ma_email.test($("#ma_email").val())) {
			$("#ma_email").css("border", "1px solid #d63d3f");
			alert("请输入正确格式的邮箱");
			return false;
		} else if($("#ma_idcard").val() == "") {
			$("#ma_idcard").css("border", "1px solid #d63d3f");
			return false;
		} else if($("#ma_idcard").val() == "") {
			$("#ma_idcard").css("border", "1px solid #d63d3f");
			return false;
		} else if(!ID_card.test($("#ma_idcard").val())) {
			$("#ma_idcard").css("border", "1px solid #d63d3f");
			alert("请输入正确格式的身份证");
			return false;
		} else if($("#img2").attr("src") == "" || $("#img3").attr("src") == "") {
			alert("请上传身份证");
			return false;
		} else {
			var datas = {
				'com_id': companyId,
				'ma_name': $("#ma_name").val(),
				'ma_phone': $("#ma_phone").val(),
				'ma_email': $("#ma_email").val(),
				'ma_idcard': $("#ma_idcard").val(),
				'ma_icimg': $("#img2").attr("src"),
				'ma_icimg1': $("#img3").attr("src"),
				'ma_position': $("#ma_position").val(),
			};
			var data = JSON.stringify(datas);
			$.ajax({
				type: "post",
				url: 'http://139.224.208.224:8080/qi-radar/company/addComManager',
				dataType: 'json',
				contentType: "application/json ",
				asycn: false,
				data: data,
				success: function(data) {
					$(".ID_card_box").hide();
					if(data.code == 0) {
						alert("新增成功")
						$("#ma_name").val("");
						$("#ma_phone").val("");
						$("#ma_email").val("");
						$("#ma_idcard").val("");
						$("#ma_position").val("");
					} else {
						alert(data.errMsg)
					};
				}
			});
		}
	};
</script>